package algorithm.搜索法;


/**
 * @author Jun
 */
public class phoneList {
    public static void main(String[] args) {
        Contact test,found;
        Contact[] friends=new Contact[8];
        friends[0]=new Contact("John","Smith","020-222-7384");
        friends[1]=new Contact("Tom","Barnes","021-333-7384");
        friends[2]=new Contact("Larry","Riley","022-444-7384");
        friends[3]=new Contact("Sam","Getz","023-555-7384");
        friends[4]=new Contact("Amny","Phelps","024-666-7384");
        friends[5]=new Contact("Sarach","Grant","025-777-7384");

        test=new Contact("Sam","Getz","");
        found=(Contact) Searching.linearSearch(friends,test);
        if(found!=null){
            System.out.println("Found"+found);
        }
        else{
            System.out.println("The contact was not found");
        }
        System.out.println();

        test=new Contact("Amny","Phelps","");
        found=(Contact) Searching.binarySearch(friends,test);
        if(found!=null){
            System.out.println("Found"+found);
        }
        else{
            System.out.println("The contact was not found");
        }

    }
}
